package com.guo.hui.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guo.hui.dao.shiro.TpUserMapper;
import com.guo.hui.model.blog.TpArticle;
import com.guo.hui.model.shiro.TpUser;
import com.guo.hui.page.PageParam;
import com.guo.hui.service.TpUserShiroService;

@Service("tpUserShiroService")
public class TpUserShiroServiceImpl implements TpUserShiroService {

	@Autowired
	private TpUserMapper userDao;

	@Override
	public List<TpUser> selectByMap(Map<String, Object> map) {

		return userDao.selectByMap(map);
	}

	@Override
	public TpUser loginAuth(String username, String password) {
		return userDao.loginAuth(username, password);
	}

	@Override
	public void updateUser(TpUser tp) {
		tp.setModifyDate(new Date());
		userDao.update(tp);

	}

	@Override
	public void saveUser(TpUser tp) {
		tp.setModifyDate(new Date());
		userDao.insert(tp);
	}

	@Override
	public PageInfo<TpUser> selectByMapPage(PageParam pageParm) {
		PageHelper.startPage(pageParm.getPage(), pageParm.getPageSize());
		List<TpUser> list = userDao.selectByMap(pageParm.getSearchContent());
		return new PageInfo<TpUser>(list);
	}

}
